﻿using System;
using System.Windows.Data;
using System.Text.RegularExpressions;

namespace ZFCNew.Converters
{
    public class HtmlTextConverter : IValueConverter
    {
        private const int defaultStringLength = 255;
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            // Hey!! do it in proper way
            if (value is string)
            {
                string res=(string) value;
                string r1 = "^<p>";
                string r2 = "</p>$";
                res = Regex.Replace(res, r1, "");
                res = Regex.Replace(res, r2, "");
                return res;// "<p>" + value + "</p>";
            }
            else
            {
                throw new InvalidOperationException("value must be string");
            }

        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
